package com.jdz.noise.service.impl;

import com.jdz.noise.dao.SphereDao;
import com.jdz.noise.exceptions.SphereException;
import com.jdz.noise.service.SphereService;
import com.jdz.noise.tools.ControlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;

/**
 * sphere service 实现类
 */
@Service
public class SphereServiceImpl implements SphereService {
    @Autowired
    private SphereDao sphereDao;

    @Override
    public int addSphereData(Integer id, String model) throws SphereException{
        int res=this.sphereDao.addSphereData(id, model);
        if(res<1){
            //抛出异常
            throw new SphereException("添加失败");
        }else{
            return res;
        }
    }
    /**
     * 将controlutil的Map_3D_Noise存入到sphere
     */
    @Override
    public int addMap_3D_Noise(Integer id){
        return this.addSphereData(id, ControlUtil.toJson_Map_3D_Noise());
    }
}

